package com.ruoyi.saleReturn.saleReturnStatusMachine;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 销售退货执行器工厂
 */
@Component
public class SaleReturnServiceFactory {

    private final Map<String, SaleReturnService> content = new HashMap<>();

    /**
     * 整合工厂
     * @param services
     */
    @Autowired
    public SaleReturnServiceFactory(List<SaleReturnService> services) {
        services.forEach(service -> content.put(service.get(), service));
    }

    /**
     * 获取工厂
     * @param flag
     * @return
     */
    public SaleReturnService getImpl(String flag) {
        return content.get(flag);
    }
}
